
package com.liao.badminton.controller;

import com.github.pagehelper.PageInfo;
import com.liao.badminton.code.*;
import com.liao.badminton.dto.BoutRecordDto;
import com.liao.badminton.dto.StatDto;
import com.liao.badminton.service.BoutRecordService;
import com.liao.badminton.vo.BoutRecordVo;
import com.liao.badminton.vo.StatVo;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestBody;
import com.liao.badminton.code.validation.Delete;
import com.liao.badminton.code.validation.Insert;
import com.liao.badminton.code.validation.Update;
import com.liao.badminton.code.validation.FindDetail;
import org.springframework.validation.annotation.Validated;

import java.util.Date;
import java.util.List;

/**
* @author liaocheng
* @date 2024-11-01
* description:单局详情表
*/
@RestController
@RequestMapping(value = "/boutRecord")
 @PreAuthorize("@ss.hasPermission('boutRecord')")//权限管理;
public class BoutRecordController {

  //  private static  Logger logger= LoggerFactory.getLogger(BoutRecordController.class);

    @Autowired
    private BoutRecordService boutRecordService;




    /**
    * 新增boutRecord
    */
    @RequestMapping(value = "/add")
    @PreAuthorize("@ss.hasPermission('boutRecord:add')")//权限管理;
    public ResponseRest<Long> add(@RequestBody @Validated(Insert.class) BoutRecordDto boutRecord)throws ProjectException{
        return boutRecordService.saveBoutRecord(boutRecord);
    }
    /**
    * 批量删除
    */
    @RequestMapping(value = "/deletes")
    @PreAuthorize("@ss.hasPermission('boutRecord:deletes')")//权限管理;
    public ResponseRest<Boolean> deletes(@RequestBody @Validated(Delete.class) BoutRecordDto param)throws ProjectException{
        return boutRecordService.deletesBoutRecord(param);
    }
    /**
    * 修改boutRecord
    */
    @RequestMapping(value = "/update")
    @PreAuthorize("@ss.hasPermission('boutRecord:update')")//权限管理;
    public ResponseRest<Boolean> update(@RequestBody @Validated(Update.class) BoutRecordDto param)throws ProjectException{
        return boutRecordService.updateBoutRecord(param);
    }

    @RequestMapping(value = "/findDetail")
    @PreAuthorize("@ss.hasPermission('BoutRecord:findDetail')")//权限管理;
    public ResponseRest<BoutRecordDto> findDetail(@RequestBody @Validated(FindDetail.class) BoutRecordDto param) throws ProjectException {
      return boutRecordService.findDetail(param);
    }
    /**
    * 分页查询列表
    */
    @RequestMapping(value = "/list")
    @PreAuthorize("@ss.hasPermission('boutRecord:list')")//权限管理;
    public ResponseRest<PageInfo<BoutRecordVo>> list(@RequestBody PageParam<BoutRecordDto> body) throws ProjectException{
      return   boutRecordService.findBoutRecordByPageParam(body);
    }

    /**
     * 队伍战绩统计(总计)
     */
    @RequestMapping(value = "/teamStat")
    @PreAuthorize("@ss.hasPermission('boutRecord:teamStat')")//权限管理;
    public ResponseRest<StatVo> findTeamStat(@RequestBody StatDto param) throws ProjectException {
        return   boutRecordService.findTeamStat(param);
    }

    /**
     * 队伍战绩统计（项） group by import
     */
    @RequestMapping(value = "/teamStatImport")
    @PreAuthorize("@ss.hasPermission('boutRecord:teamStatImport')")//权限管理;
    public ResponseRest<PageInfo<StatVo>> findTeamStatImport(@RequestBody PageParam<StatDto> param) throws ProjectException {
        return   boutRecordService.findTeamStatImport(param);
    }

    /**
     * 队伍战绩统计group by import
     */
    @RequestMapping(value = "/txtByImport")
    @PreAuthorize("@ss.hasPermission('boutRecord:txtByImport')")//权限管理;
    public ResponseRest<String> txtByImport(@RequestBody StatDto param) throws ProjectException {
        return   boutRecordService.txtByImport(param);
    }


    /**
     *
     */
    @RequestMapping(value = "/findMostTeam")
    @PreAuthorize("@ss.hasPermission('boutRecord:findMostTeam')")//权限管理;
    public ResponseRest<List<StatVo>> findMostTeam(@RequestBody StatDto param) throws ProjectException {
        return   boutRecordService.findMostTeam(param);
    }

}
